<?php

namespace app\api\module;

use app\common\model\Broker;
use app\common\model\BrokerComment;
use app\common\model\BrokerSearch;
use app\common\model\Community;
use app\common\model\CommunityCompare;
use app\common\model\CommunitySearch;
use app\common\model\CommunityStrategy;
use app\common\model\CommunityTrend;
use app\common\model\ErrorFeedbackLog;
use app\common\model\HelpFind;
use app\common\model\House as HouseModel;
use app\common\model\HouseAnalysis;
use app\common\model\HouseComCompare;
use app\common\model\HouseCompare;
use app\common\model\HouseMoment;
use app\common\model\HousePubLog;
use app\common\model\HouseRefLog;
use app\common\model\HouseSearch;
use app\common\model\MyHouse;
use app\common\model\NewHouse;
use app\common\model\UserAttention;
use app\common\model\ViewFeedbackLog;
use think\facade\Db;

class House extends Common
{
    /**
     * 判断是否需要登录
     *
     * @param string $interface 待检测的接口
     * @return bool
     */
    protected function needLogin($interface)
    {
        //不需登录的接口https://docs.qq.com/doc/DWGZNZU5YZXJwbmRj
        $ignoreList = [
            ZFN_HOUSE_INDEX,
            ZFN_HOUSE_KEYWORD_COMMUNITY,
            ZFN_HOUSE_REF_INFO,
            ZFN_HOUSE_ADD_MY_INFO,
            ZFN_HOUSE_HELP_FIND_INFO,
            ZFN_HOUSE_SECOND_TOP,
            ZFN_HOUSE_SECOND_SEARCH_DATA,
            ZFN_HOUSE_SECOND_LIST,
            ZFN_HOUSE_COMMUNITY_SECOND_SEARCH_DATA,
            ZFN_HOUSE_COMMUNITY_SECOND_LIST,
            ZFN_HOUSE_COMMUNITY_SEARCH_DATA,
            ZFN_HOUSE_COMMUNITY_LIST,

            ZFN_HOUSE_BROKER_SEARCH_DATA,
            ZFN_HOUSE_BROKER_LIST,
            ZFN_HOUSE_BROKER_DETAIL,
            ZFN_HOUSE_BROKER_COMMENT_LIST,
            ZFN_HOUSE_MOMENT,

            ZFN_HOUSE_COMMUNITY_DETAIL,
            ZFN_HOUSE_COMMUNITY_STRATEGY,
            ZFN_HOUSE_COMMUNITY_PRICE_STEP,

            ZFN_HOUSE_COMMUNITY_COMPARE,
            ZFN_HOUSE_COMPARE,
            ZFN_HOUSE_COM_COMPARE,
            ZFN_HOUSE_NEW_LIST,
            ZFN_HOUSE_NEW_BEDROOM
        ];

        if (in_array($interface, $ignoreList)) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * 执行接口操作
     *
     * @param $interface
     * @return array|string
     */
    public function exec($interface)
    {
        switch ($interface) {
            //【1001】首页
            case ZFN_HOUSE_INDEX:
                return $this->index();
            //【1002】信息纠错提交
            case ZFN_HOUSE_ERROR_SUB:
                return $this->errorSub();
            //【1003】小区名称搜索小区
            case ZFN_HOUSE_KEYWORD_COMMUNITY:
                return $this->keywordCommunity();
            //【1004】获取房屋估价提交所需的选项信息
            case ZFN_HOUSE_REF_INFO:
                return $this->houseRefInfo();
            //【1005】房屋估价提交
            case ZFN_HOUSE_REF_SUB:
                return $this->houseRefSub();
            //【1006】我的家房屋列表
            case ZFN_HOUSE_MY_LIST:
                return $this->myHouseList();
            //【1007】获取添加房屋所需的选项信息
            case ZFN_HOUSE_ADD_MY_INFO:
                return $this->myHouseSubInfo();
            //【1008】添加房屋提交
            case ZFN_HOUSE_ADD_MY_SUB:
                return $this->myHouseAdd();
            //【1009】编辑房屋提交
            case ZFN_HOUSE_EDIT_MY_SUB:
                return $this->myHouseEdit();
            //【1010】删除我的房屋
            case ZFN_HOUSE_DEL_MY:
                return $this->myHouseDel();

            //【1011】我要卖房信息页
            case ZFN_HOUSE_PUB_INFO:
                return $this->housePubInfo();
            //【1012】我要卖房信息页
            case ZFN_HOUSE_SELL_PUB_SUB:
                return $this->sellSub();
            //【1013】我要卖房信息页
            case ZFN_HOUSE_RENT_SUB:
                return $this->rentSub();
            //【1014】业主服务页
            case ZFN_HOUSE_PUB_CENTER:
                return $this->pubCenter();

            //【1015】换房计算器房屋列表
            case ZFN_HOUSE_CAL_LIST:
                return $this->myHouseCalList();
            //【1016】房屋价格提交
            case ZFN_HOUSE_CAL_PRICE_SUB:
                return $this->myHousePriceSub();
            //【1017】获取房贷信息
            case ZFN_HOUSE_GET_LOAN:
                return $this->myHouseLoan();
            //【1018】房贷提交
            case ZFN_HOUSE_LOAN_SUB:
                return $this->myHouseLoanSub();
            //【1019】换房信息页
            case ZFN_HOUSE_EXCHANGE_INFO:
                return $this->myHouseExchangeInfo();
            //【1020】换房提交
            case ZFN_HOUSE_EXCHANGE_SUB:
                return $this->myHouseExchangeSub();
            //【1021】换房计算结果更改参数提交
            case ZFN_HOUSE_EXCHANGE_RES_SUB:
                return $this->myHouseCalExchangeRes();
            //【1022】换房计算器忽略房贷
            case ZFN_HOUSE_LOAN_IGNORE:
                return $this->myHouseLoanIgnore();

            //【1023】帮我找房获取信息
            case ZFN_HOUSE_HELP_FIND_INFO:
                return $this->helpFindInfo();
            //【1024】帮我找房提交
            case ZFN_HOUSE_HELP_FIND_SUB:
                return $this->helpFindSub();

            //【1025】我的家详情顶部
            case ZFN_HOUSE_MY_DETAIL_TOP:
                return $this->myDetailTop();
            //【1026】我的家详情
            case ZFN_HOUSE_MY_DETAIL:
                return $this->myDetail();

            //【1027】二手房顶部
            case ZFN_HOUSE_SECOND_TOP:
                return $this->secondTop();
            //【1028】二手房、法拍房筛选项目
            case ZFN_HOUSE_SECOND_SEARCH_DATA:
                return $this->secondSearchData();
            //【1029】二手房、法拍房列表
            case ZFN_HOUSE_SECOND_LIST:
                return $this->secondList();
            //【1030】小区下二手房筛选项目
            case ZFN_HOUSE_COMMUNITY_SECOND_SEARCH_DATA:
                return $this->communitySecondSearchData();
            //【1031】小区下二手房列表
            case ZFN_HOUSE_COMMUNITY_SECOND_LIST:
                return $this->communitySecondList();

            //【1032】小区筛选项
            case ZFN_HOUSE_COMMUNITY_SEARCH_DATA:
                return $this->communitySearchData();
            //【1033】小区筛选列表
            case ZFN_HOUSE_COMMUNITY_LIST:
                return $this->communityList();

            //【1034】关注二手、法拍、租房、小区、经纪人操作
            case ZFN_HOUSE_ATTENTION_DO:
                return $this->attentionDo();
            //【1035】关注记录
            case ZFN_HOUSE_ATTENTION_LIST:
                return $this->attentionList();

            //【1036】经纪人筛选项
            case ZFN_HOUSE_BROKER_SEARCH_DATA:
                return $this->brokerSearchData();
            //【1037】找经纪人列表
            case ZFN_HOUSE_BROKER_LIST:
                return $this->brokerList();
            //【1038】经纪人详情
            case ZFN_HOUSE_BROKER_DETAIL:
                return $this->brokerDetail();
            //【1039】经纪人评价列表
            case ZFN_HOUSE_BROKER_COMMENT_LIST:
                return $this->brokerComment();
            //【1040】分享经纪人
            case ZFN_HOUSE_BROKER_SHARE:
                return $this->brokerShare();

            //【1041】二手、法拍房详情
            case ZFN_HOUSE_DETAIL:
                return $this->houseDetail();
            //【1042】二手、法拍房动态
            case ZFN_HOUSE_MOMENT:
                return $this->houseMoment();
            //【1043】二手、法拍房分享
            case ZFN_HOUSE_SHARE:
                return $this->houseShare();
            //【1044】二手、法拍房户型报告
            case ZFN_HOUSE_ANALYSIS:
                return $this->houseAnalysis();

            //【1045】小区详情
            case ZFN_HOUSE_COMMUNITY_DETAIL:
                return $this->communityDetail();
            //【1046】小区分享
            case ZFN_HOUSE_COMMUNITY_SHARE:
                return $this->communityShare();
            //【1047】小区攻略
            case ZFN_HOUSE_COMMUNITY_STRATEGY:
                return $this->communityStrategy();
            //【1048】小区攻略分享
            case ZFN_HOUSE_COMMUNITY_STRATEGY_SHARE:
                return $this->communityStrategyShare();
            //【1049】小区价格走势
            case ZFN_HOUSE_COMMUNITY_PRICE_STEP:
                return $this->communityPriceStep();
            //【1050】小区价格走势分享
            case ZFN_HOUSE_COMMUNITY_PRICE_STEP_SHARE:
                return $this->communityPriceStepShare();

            //【1051】二手房聊天发送户型报告
            case ZFN_HOUSE_CHAT_ANALYSIS:
                return $this->chatAnalysis();

            //【1052】小区比对
            case ZFN_HOUSE_COMMUNITY_COMPARE:
                return $this->communityCompare();
            //【1053】二手法拍房基本信息比对
            case ZFN_HOUSE_COMPARE:
                return $this->houseCompare();
            //【1054】二手法拍房房评信息比对
            case ZFN_HOUSE_COM_COMPARE:
                return $this->houseComCompare();
            //【1055】新房列表
            case ZFN_HOUSE_NEW_LIST:
                return $this->newHouseList();
            //【1056】新房小区详情
            case ZFN_HOUSE_NEW_DETAIL:
                return $this->newHouseDetail();
            //【1057】新房居室分布
            case ZFN_HOUSE_NEW_BEDROOM:
                return $this->newHouseBedroom();
            default:
                send_developer_error("模块【二手房】中不存在接口【" . $interface . "】,核实文档后重试!");
        }
    }
    //新房居室分布
    private function newHouseBedroom(){
        $community_id = $this->essentialParam('community_id');
        $bedroom_id = $this->essentialParam('bedroom_id');
        $data = NewHouse::bedroomList($community_id,$bedroom_id);
        $this->insertResponse('data',$data);
        return $this->response('新房居室分布');
    }
    //新房小区详情
    private function newHouseDetail(){
        $user = $this->currentUser();
        $community_id = $this->essentialParam('community_id');
        $data = Community::newDetail($community_id,$user);
        $this->insertResponse('',$data);
        return $this->response('新房详情');
    }
    //新房列表
    private function newHouseList()
    {
        $user = $this->currentUser(false);
        $city_id = $this->essentialParam('city_id');
        $keyword = $this->optionalParam('keyword');
        $area_id = $this->optionalParam('area_id');
        $district_ids = $this->optionalParam('district_ids');
        $nearby = $this->optionalParam('nearby');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $sel_data = [
            'price_min' => $this->optionalParam('price_min'),
            'price_max' => $this->optionalParam('price_max'),
            'floor_type' => $this->optionalParam('floor_type'),
            'build_age' => $this->optionalParam('build_age'),
            'delivery_type' => $this->optionalParam('delivery_type'),
        ];
        $sort = $this->optionalParam('sort');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = Community::newHouseList($user,$city_id,$keyword,$area_id,$district_ids,$nearby,$longitude,$latitude,$sel_data,$sort,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('新房列表');
    }
    private function index()
    {
        $user = $this->currentUser(false);
        $city_id = $this->essentialParam('city_id');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $data = HouseModel::index($user,$city_id,$longitude,$latitude);
        $this->insertResponse('',$data);
        return $this->response('首页');
    }

    private function errorSub()
    {
        $user = $this->currentUser();
        $source_type = $this->essentialParam('source_type');
        $source_id = $this->essentialParam('source_id');
        $content = $this->essentialParam('content');
        $imgs = $this->optionalParam('imgs');
        $type = $this->essentialParam('type');
        ErrorFeedbackLog::sub($user,$source_type,$source_id,$content,$imgs,$type);
        return $this->response('提交成功');
    }

    private function keywordCommunity()
    {
        $city_id = $this->essentialParam('city_id');
        $keyword = $this->essentialParam('keyword');
        $type = $this->optionalParam('type');
        $data = Community::keywordSearch($city_id,$keyword,$type);
        $this->insertResponse('data',$data);
        return $this->response('小区名称搜索小区');
    }


    private function houseRefInfo()
    {
        $data = HouseRefLog::getSubInfo();
        $this->insertResponse('',$data);
        return $this->response('获取房屋估价提交所需的选项信息');
    }

    private function houseRefSub()
    {
        $user = $this->currentUser();
        $params = [
            'community_id' => $this->essentialParam('community_id'),
            'bedroom' => $this->essentialParam('bedroom'),
            'living' => $this->essentialParam('living'),
            'restroom' => $this->essentialParam('restroom'),
            'build_area' => $this->essentialParam('build_area'),
            'house_direct' => $this->essentialParam('house_direct'),
            'in_floor' => $this->essentialParam('in_floor'),
            'all_floor' => $this->essentialParam('all_floor'),
            'house_decorate' => $this->optionalParam('house_decorate'),
            'ext_area' => $this->optionalParam('ext_area'),
        ];
        HouseRefLog::sub($user,$params);
        return $this->response('提交成功');
    }

    private function myHouseList()
    {
        $user = $this->currentUser();
        $data = MyHouse::getList($user);
        $this->insertResponse('',$data);
        return $this->response('我的房屋列表');
    }


    private function myHouseSubInfo()
    {
        $house_id = $this->optionalParam('house_id');
        $data = MyHouse::getHouseInfo($house_id);
        $this->insertResponse('',$data);
        return $this->response('获取添加房屋所需的选项信息');
    }

    private function myHouseAdd()
    {
        $user = $this->currentUser();
        $params = [
            'community_id' => $this->essentialParam('community_id'),
            'bedroom' => $this->essentialParam('bedroom'),
            'living' => $this->essentialParam('living'),
            'restroom' => $this->essentialParam('restroom'),
            'build_area' => $this->essentialParam('build_area'),
            'house_direct' => $this->essentialParam('house_direct'),
            'in_floor' => $this->essentialParam('in_floor'),
            'all_floor' => $this->essentialParam('all_floor'),
            'build_number' => $this->essentialParam('build_number'),
            'unit_number' => $this->essentialParam('unit_number'),
            'room_number' => $this->essentialParam('room_number'),
        ];
        MyHouse::addSub($user,$params);
        return $this->response('添加成功');
    }

    private function myHouseEdit()
    {
        $user = $this->currentUser();
        $params = [
            'id' => $this->essentialParam('house_id'),
            'community_id' => $this->essentialParam('community_id'),
            'bedroom' => $this->essentialParam('bedroom'),
            'living' => $this->essentialParam('living'),
            'restroom' => $this->essentialParam('restroom'),
            'build_area' => $this->essentialParam('build_area'),
            'house_direct' => $this->essentialParam('house_direct'),
            'in_floor' => $this->essentialParam('in_floor'),
            'all_floor' => $this->essentialParam('all_floor'),
            'build_number' => $this->essentialParam('build_number'),
            'unit_number' => $this->essentialParam('unit_number'),
            'room_number' => $this->essentialParam('room_number'),
        ];
        MyHouse::editSub($user,$params);
        return $this->response('编辑成功');
    }


    private function myHouseDel()
    {
        $user = $this->currentUser();
        $id = $this->essentialParam('house_id');
        MyHouse::delSub($user,$id);
        return $this->response('删除成功');
    }

    private function housePubInfo()
    {
        $user = $this->currentUser();
        $data = HousePubLog::getPubInfo($user);
        $this->insertResponse('',$data);
        return $this->response('我要卖房信息页');
    }

    private function sellSub()
    {
        $user = $this->currentUser();
        $params = [
            'community_id' => $this->essentialParam('community_id'),
            'build_number' => $this->essentialParam('build_number'),
            'unit_number' => $this->essentialParam('unit_number'),
            'room_number' => $this->essentialParam('room_number'),
            'price' => $this->essentialParam('price'),
            'name' => $this->essentialParam('name'),
        ];
        HousePubLog::sellSub($user,$params);
        return $this->response('卖房发布成功');
    }

    private function rentSub()
    {
        $user = $this->currentUser();
        $params = [
            'community_id' => $this->essentialParam('community_id'),
            'build_number' => $this->essentialParam('build_number'),
            'unit_number' => $this->essentialParam('unit_number'),
            'room_number' => $this->essentialParam('room_number'),
            'price' => $this->essentialParam('price'),
            'name' => $this->essentialParam('name'),
        ];
        HousePubLog::rentSub($user,$params);
        return $this->response('租房发布成功');
    }

    private function pubCenter()
    {
        $user = $this->currentUser();
        $data = HousePubLog::pubCenter($user);
        $this->insertResponse('',$data);
        return $this->response('业主服务页');
    }

    private function myHouseCalList()
    {
        $user = $this->currentUser();
        $data = MyHouse::getCalHouseList($user);
        $this->insertResponse('',$data);
        return $this->response('换房计算器房屋列表');
    }

    //房屋价格提交
    private function myHousePriceSub()
    {
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        $price = $this->essentialParam('price');
        MyHouse::priceSub($user,$house_id,$price);
        return $this->response('修改成功');
    }

    private function myHouseLoan()
    {
        $house_id = $this->essentialParam('house_id');
        $data = MyHouse::getHouseLoan($house_id);
        $this->insertResponse('',$data);
        return $this->response('获取房贷信息');
    }

    private function myHouseLoanSub()
    {
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        $loan_type = $this->essentialParam('loan_type');
        $pay_type = $this->essentialParam('pay_type');
        $rate_type = $this->optionalParam('rate_type');
        $money1 = $this->optionalParam('money1');
        $rate1 = $this->optionalParam('rate1');
        $num1 = $this->optionalParam('num1');
        $money2 = $this->optionalParam('money2');
        $rate2 = $this->optionalParam('rate2');
        $num2 = $this->optionalParam('num2');
        $first_pay_time = $this->essentialParam('first_pay_time');
        $pre_sell_time = $this->essentialParam('pre_sell_time');
        MyHouse::loanSub($user,$house_id,$loan_type,$pay_type,$rate_type,$money1,$rate1,$num1,$money2,$rate2,$num2,$first_pay_time,$pre_sell_time);
        return $this->response('保存成功');
    }

    private function myHouseExchangeInfo()
    {
        $data = MyHouse::exchangeInfo();
        $this->insertResponse('',$data);
        return $this->response('换房信息页');
    }

    private function myHouseExchangeSub()
    {
        $house_ids = $this->essentialParam('house_ids');
        $money = $this->essentialParam('money');
        $payment_type = $this->essentialParam('payment_type');
        $data = MyHouse::exchangeSub($house_ids,$money,$payment_type);
        $this->insertResponse('',$data);
        return $this->response('换房提交');
    }

    private function myHouseCalExchangeRes()
    {
        $income_all = $this->essentialParam('income_all');
        $money = $this->essentialParam('money');
        $loan_type = $this->essentialParam('loan_type');
        $pay_type = $this->essentialParam('pay_type');
        $money1 = $this->optionalParam('money1');
        $rate1 = $this->optionalParam('rate1');
        $num1 = $this->optionalParam('num1');
        $money2 = $this->optionalParam('money2');
        $rate2 = $this->optionalParam('rate2');
        $num2 = $this->optionalParam('num2');
        $data = MyHouse::calExchangeMonthMoney($loan_type,$pay_type,$money1,$rate1,$num1,$money2,$rate2,$num2,$income_all,$money);
        $this->insertResponse('',$data);
        return $this->response('换房计算结果更改参数提交');
    }

    private function myHouseLoanIgnore()
    {
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        MyHouse::loanIgnore($user,$house_id);
        return $this->response('忽略成功');
    }

    private function helpFindInfo()
    {
        $city_id = $this->essentialParam('city_id');
        $data = HelpFind::getInfo($city_id);
        $this->insertResponse('',$data);
        return $this->response('帮我找房信息');
    }

    private function helpFindSub()
    {
        $user = $this->currentUser();
        $city_id = $this->essentialParam('city_id');
        $price_min = $this->optionalParam('price_min');
        $price_max = $this->optionalParam('price_max');
        $bed_room = $this->essentialParam('bed_room');
        $area_id = $this->optionalParam('area_id');
        $district_ids = $this->optionalParam('district_ids');
        $purpose = $this->optionalParam('purpose');
        $area = $this->optionalParam('area');
        $direct = $this->optionalParam('direct');
        $floor = $this->optionalParam('floor');
        $age = $this->optionalParam('age');
        $extra = $this->optionalParam('extra');
        HelpFind::helpSub($user,$city_id,$price_min,$price_max,$bed_room,$area_id,$district_ids,$purpose,$area,$direct,$floor,$age,$extra);
        return $this->response('提交成功，感谢您的信任平台会尽快为您查找匹配房源并与您联系');
    }

    private function myDetailTop()
    {
        $user = $this->currentUser();
        $data = MyHouse::myDetailTop($user);
        $this->insertResponse('',$data);
        return $this->response('我的家详情顶部');
    }

    private function myDetail()
    {
        $community_id = $this->essentialParam('community_id');
        $data = MyHouse::myDetail($community_id);
        $this->insertResponse('',$data);
        return $this->response('我的家详情数据');
    }

    private function secondTop()
    {
        $data = HouseModel::secondTop();
        $this->insertResponse('',$data);
        return $this->response('二手房模块顶部');
    }

    private function secondSearchData()
    {
        $city_id = $this->essentialParam('city_id');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $data = HouseSearch::secondSearchData($city_id,$longitude,$latitude);
        $this->insertResponse('',$data);
        return $this->response('二手房、法拍房筛选项目数据');
    }

    private function secondList()
    {
        $house_type = $this->essentialParam('house_type');
        $city_id = $this->essentialParam('city_id');
        $keyword = $this->optionalParam('keyword');
        $area_id = $this->optionalParam('area_id');
        $district_ids = $this->optionalParam('district_ids');
        $nearby = $this->optionalParam('nearby');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $sel_data = [
            'price_min' => $this->optionalParam('price_min'),
            'price_max' => $this->optionalParam('price_max'),
            'bedroom' => $this->optionalParam('bedroom'),
            'restroom' => $this->optionalParam('restroom'),
            'build_area' => $this->optionalParam('build_area'),
            'house_direct' => $this->optionalParam('house_direct'),
            'house_analysis' => $this->optionalParam('house_analysis'),
            'house_tags' => $this->optionalParam('house_tags'),
            'floor_tag' => $this->optionalParam('floor_tag'),
            'build_age' => $this->optionalParam('build_age'),
            'house_decorate' => $this->optionalParam('house_decorate'),
            'house_purpose' => $this->optionalParam('house_purpose'),
            'heating_type' => $this->optionalParam('heating_type'),
            'trade_type' => $this->optionalParam('trade_type'),
            'build_type' => $this->optionalParam('build_type'),
        ];
        $sort = $this->optionalParam('sort');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = HouseModel::secondList($house_type,$city_id,$keyword,$area_id,$district_ids,$nearby,$longitude,$latitude,$sel_data,$sort,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('二手房、法拍房列表');
    }

    private function communitySecondSearchData()
    {
        $community_id = $this->essentialParam('community_id');
        $data = HouseSearch::communitySecondSearchData($community_id);
        $this->insertResponse('',$data);
        return $this->response('小区下二手房筛选项目数据');
    }

    private function communitySecondList()
    {
        $community_id = $this->essentialParam('community_id');
        $sel_data = [
            'price_min' => $this->optionalParam('price_min'),
            'price_max' => $this->optionalParam('price_max'),
            'bedroom' => $this->optionalParam('bedroom'),
            'restroom' => $this->optionalParam('restroom'),
            'build_area' => $this->optionalParam('build_area'),
            'house_direct' => $this->optionalParam('house_direct'),
            'house_analysis' => $this->optionalParam('house_analysis'),
            'house_tags' => $this->optionalParam('house_tags'),
            'floor_tag' => $this->optionalParam('floor_tag'),
            'build_age' => $this->optionalParam('build_age'),
            'house_decorate' => $this->optionalParam('house_decorate'),
            'house_purpose' => $this->optionalParam('house_purpose'),
            'heating_type' => $this->optionalParam('heating_type'),
            'trade_type' => $this->optionalParam('trade_type'),
            'build_type' => $this->optionalParam('build_type'),
        ];
        $sort = $this->optionalParam('sort');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = HouseModel::communitySecondList($community_id,1,$sel_data,$sort,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('二手房列表');
    }

    private function communitySearchData()
    {
        $city_id = $this->essentialParam('city_id');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $data = CommunitySearch::searchData($city_id,$longitude,$latitude);
        $this->insertResponse('',$data);
        return $this->response('小区筛选项目数据');
    }

    private function communityList()
    {
        $user = $this->currentUser(false);
        $city_id = $this->essentialParam('city_id');
        $keyword = $this->optionalParam('keyword');
        $area_id = $this->optionalParam('area_id');
        $district_ids = $this->optionalParam('district_ids');
        $nearby = $this->optionalParam('nearby');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $sel_data = [
            'price_min' => $this->optionalParam('price_min'),
            'price_max' => $this->optionalParam('price_max'),
            'build_type' => $this->optionalParam('build_type'),
            'build_age' => $this->optionalParam('build_age'),
        ];
        $sort = $this->optionalParam('sort');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = Community::searchList($user,$city_id,$keyword,$area_id,$district_ids,$nearby,$longitude,$latitude,$sel_data,$sort,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('小区列表');
    }

    private function attentionDo()
    {
        $user = $this->currentUser();
        $type = $this->essentialParam('type');
        $ob_id = $this->essentialParam('ob_id');
        $do_type = $this->essentialParam('do_type');
        $info = UserAttention::attentionDo($user,$type,$ob_id,$do_type);
        return $this->response($info);
    }

    private function attentionList()
    {
        $user = $this->currentUser();
        $type = $this->essentialParam('type');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = UserAttention::attentionList($user,$type,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('关注记录');
    }

    private function brokerSearchData()
    {
        $city_id = $this->essentialParam('city_id');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');
        $data = BrokerSearch::searchData($city_id,$longitude,$latitude);
        $this->insertResponse('',$data);
        return $this->response('经纪人筛选项目数据');
    }

    private function brokerList()
    {
        $city_id = $this->essentialParam('city_id');
        $keyword = $this->optionalParam('keyword');
        $area_id = $this->optionalParam('area_id');
        $district_ids = $this->optionalParam('district_ids');
        $nearby = $this->optionalParam('nearby');
        $longitude = $this->optionalParam('longitude');
        $latitude = $this->optionalParam('latitude');

        $sort = $this->optionalParam('sort');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = Broker::searchList($city_id,$keyword,$area_id,$district_ids,$nearby,$longitude,$latitude,$sort,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('找经纪人列表');
    }

    private function brokerDetail(){
        $user = $this->currentUser(false);
        $broker_id = $this->essentialParam('broker_id');
        $data = Broker::detail($user,$broker_id);
        $this->insertResponse('',$data);
        return $this->response('经纪人详情');
    }

    private function brokerComment(){
        $broker_id = $this->essentialParam('broker_id');
        $page = $this->essentialParam('page');
        $page_size = $this->essentialParam('page_size');
        $data = BrokerComment::getList($broker_id,$page,$page_size);
        $this->insertResponse('data',$data);
        return $this->response('经纪人评价列表');
    }

    private function brokerShare(){
        $user = $this->currentUser();
        $broker_id = $this->essentialParam('broker_id');
        $data = Broker::share($user,$broker_id);
        $this->insertResponse('',$data);
        return $this->response('经纪人分享小程序');
    }

    private function houseDetail(){
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        $data = HouseModel::detail($house_id,$user);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房详情');
    }

    private function houseMoment(){
        $house_id = $this->essentialParam('house_id');
        $data = HouseMoment::getHouseMoment($house_id);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房动态');
    }

    private function houseShare(){
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        $data = HouseModel::houseShare($user,$house_id);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房分享');
    }

    private function houseAnalysis(){
        $house_id = $this->essentialParam('house_id');
        $data = HouseAnalysis::houseAnalysis($house_id);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房户型报告');
    }

    private function communityDetail(){
        $user = $this->currentUser(false);
        $community_id = $this->essentialParam('community_id');
        $data = Community::detail($community_id,$user);
        $this->insertResponse('',$data);
        return $this->response('小区详情');
    }

    private function communityShare(){
        $user = $this->currentUser();
        $community_id = $this->essentialParam('community_id');
        $data = Community::share($user,$community_id);
        $this->insertResponse('',$data);
        return $this->response('小区分享');
    }

    private function communityStrategy(){
        $community_id = $this->essentialParam('community_id');
        $data = CommunityStrategy::detail($community_id);
        $this->insertResponse('',$data);
        return $this->response('小区攻略');
    }

    private function communityStrategyShare(){
        $user = $this->currentUser();
        $community_id = $this->essentialParam('community_id');
        $data = CommunityStrategy::share($user,$community_id);
        $this->insertResponse('',$data);
        return $this->response('小区攻略分享');
    }

    private function communityPriceStep(){
        $community_id = $this->essentialParam('community_id');
        $data = CommunityTrend::step($community_id);
        $this->insertResponse('',$data);
        return $this->response('小区价格走势');
    }

    private function communityPriceStepShare(){
        $user = $this->currentUser();
        $community_id = $this->essentialParam('community_id');
        $data = CommunityTrend::share($user,$community_id);
        $this->insertResponse('',$data);
        return $this->response('小区价格走势分享');
    }

    private function chatAnalysis(){
        $user = $this->currentUser();
        $house_id = $this->essentialParam('house_id');
        $broker_id = $this->essentialParam('broker_id');
        HouseAnalysis::chatAnalysis($user,$house_id,$broker_id);
        return $this->response('');
    }

    private function communityCompare(){
        $community_ids = $this->essentialParam('community_ids');
        $hide_same = $this->optionalParam('hide_same');
        $source = $this->essentialParam('source');
        $data = CommunityCompare::compare($community_ids,$hide_same,$source);
        $this->insertResponse('',$data);
        return $this->response('小区比对');
    }

    private function houseCompare(){
        $house_ids = $this->essentialParam('house_ids');
        $show_all = $this->optionalParam('show_all');
        $hide_same = $this->optionalParam('hide_same');
        $source = $this->essentialParam('source');
        $data = HouseCompare::compare($house_ids,$show_all,$hide_same,$source);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房基本信息比对');
    }

    private function houseComCompare(){
        $house_ids = $this->essentialParam('house_ids');

        $source = $this->essentialParam('source');
        $data = HouseComCompare::compare($house_ids,$source);
        $this->insertResponse('',$data);
        return $this->response('二手、法拍房房评信息比对');
    }
}
